/**
 * Project: push-center-biz-dal
 * 
 * File Created at 2014年10月9日
 * 
 * Copyright 2012 Greenline.com Corporation Limited.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * Greenline Company. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Greenline.com.
 */
package com.greenline.push.dal.pushcenter.impl;

import java.util.List;

import com.greenline.push.dal.base.BaseDAO;
import com.greenline.push.dal.pushcenter.CategoryDAO;
import com.greenline.push.dal.pushcenter.dataobject.CategoryDO;
import com.greenline.push.dal.query.CategoryQuery;

/**
 * @Type CategoryDAOImpl
 * @Desc 
 * @author zhaoli
 * @date 2014年10月9日
 * @Version V1.0
 */
public class CategoryDAOImpl extends BaseDAO implements CategoryDAO {

	/* (non-Javadoc)
	 * @see com.greenline.push.dal.pushcenter.CategoryDAO#insert(com.greenline.push.dal.pushcenter.dataobject.CategoryDO)
	 */
	@Override
	public Long insert(CategoryDO Category) {
		return (Long) super.getSqlMapClientTemplate().insert("category.insert", Category);
	}

	/* (non-Javadoc)
	 * @see com.greenline.push.dal.pushcenter.CategoryDAO#getCategoryById(java.lang.Long)
	 */
	@Override
	public CategoryDO getCategoryById(Long id) {
		return (CategoryDO) super.getSqlMapClientTemplate().queryForObject("category.find_by_id", id);
	}

	/* (non-Javadoc)
	 * @see com.greenline.push.dal.pushcenter.CategoryDAO#update(com.greenline.push.dal.pushcenter.dataobject.CategoryDO)
	 */
	@Override
	public int update(CategoryDO Category) {
		return super.getSqlMapClientTemplate().update("category.update", Category);
	}

	/* (non-Javadoc)
	 * @see com.greenline.push.dal.pushcenter.CategoryDAO#listByQuery(com.greenline.push.dal.query.CategoryQuery)
	 */
	@Override
	public CategoryQuery listByQuery(CategoryQuery query) {
		return (CategoryQuery) super.listByQuery("category.list_by_query", query);
	}

	/* (non-Javadoc)
	 * @see com.greenline.push.dal.pushcenter.CategoryDAO#delete(java.lang.Long)
	 */
	@Override
	public int delete(Long id) {
		return super.getSqlMapClientTemplate().delete("category.delete", id);
	}

	/* (non-Javadoc)
	 * @see com.greenline.push.dal.pushcenter.CategoryDAO#listAll()
	 */
	@Override
	@SuppressWarnings("unchecked")
	public List<CategoryDO> listAll() {
		return super.getSqlMapClientTemplate().queryForList("category.list_all");
	}

	/* (non-Javadoc)
	 * @see com.greenline.push.dal.pushcenter.CategoryDAO#getBycategoryName(java.lang.String)
	 */
	@Override
	public CategoryDO getBycategoryName(String categoryName) {
		return (CategoryDO) super.getSqlMapClientTemplate().queryForObject("category.find_by_category_name", categoryName);
	}
}
